package nccloud.pubimpl.gl.account.assattbalance;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.gl.account.glconst.CurrTypeConst;
import nc.gl.utils.GLMultiLangUtil;
import nc.itf.gl.accbook.IRemoteBillModel;
import nc.md.model.impl.Attribute;
import nc.pub.gl.free.assbal.CAssGenToolElement;
import nc.ui.glcom.balance.CAssSortTool;
import nc.ui.glcom.balance.CStringArraySortTool;
import nc.ui.glcom.balance.GlAssDeal;
import nc.vo.bd.account.AccountVO;
import nc.vo.bd.currtype.CurrtypeVO;
import nc.vo.bd.property.UserdefAttributeAdapter;
import nc.vo.fipub.freevalue.GlAssVO;
import nc.vo.gateway60.accountbook.AccountBookUtil;
import nc.vo.gateway60.dummyobject.BDAttributeDescInfo;
import nc.vo.gateway60.itfs.AccountUtilGL;
import nc.vo.gateway60.itfs.CurrtypeGL;
import nc.vo.gl.balancebooks.BalanceResultVO;
import nc.vo.gl.balancesubjass.BalanceSubjAssBSVO;
import nc.vo.gl.detailbooks.CAssTool;
import nc.vo.glcom.ass.AssCodeConstructor;
import nc.vo.glcom.ass.AssVO;
import nc.vo.glcom.balance.AssAttriVODealTool;
import nc.vo.glcom.balance.AttrsValueVO;
import nc.vo.glcom.balance.GLQueryObj;
import nc.vo.glcom.balance.GlBalanceKey;
import nc.vo.glcom.balance.GlBalanceVO;
import nc.vo.glcom.balance.GlQueryVO;
import nc.vo.glcom.balance.GlQueryVOBookTool;
import nc.vo.glcom.balance.GlQueryVOTool;
import nc.vo.glcom.inteltool.CDataSource;
import nc.vo.glcom.inteltool.CGenTool;
import nc.vo.glcom.inteltool.COutputTool;
import nc.vo.glcom.inteltool.CUFDoubleSumTool;
import nc.vo.glcom.inteltool.IBalanceTool;
import nc.vo.glcom.inteltool.IDataSource;
import nc.vo.glcom.inteltool.IGenTool;
import nc.vo.glcom.inteltool.IGenToolElement;
import nc.vo.glcom.inteltool.IGenToolElementProvider;
import nc.vo.glcom.inteltool.IOutputTool;
import nc.vo.glcom.inteltool.ISumTool;
import nc.vo.glcom.inteltool.UFDCBalanceTool;
import nc.vo.glcom.inteltool.ZeroUFdoubleConstant;
import nc.vo.glcom.intelvo.CIntelVO;
import nc.vo.glcom.sorttool.CVoSortTool;
import nc.vo.glcom.sorttool.ISortTool;
import nc.vo.glcom.sorttool.ISortToolProvider;
import nc.vo.glcom.wizard.VoWizard;
import nc.vo.glpub.IVoAccess;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.org.AccountingBookVO;
import nc.vo.pub.BusinessException;
import nccloud.pubimpl.gl.account.subjassemble.CAccountGenToolElement;

public class AssAttBalanceWebModel implements IGenToolElementProvider, ISortToolProvider {
	BalanceSubjAssBSVO[] m_dataVOs;

	GlAssVO[] assVOs = new GlAssVO[0];

	GlQueryVO[] queryVOs = null;

	GlQueryVO m_qryVO = null;

	IGenToolElement m = null;

	IGenToolElement assGenElement = null;

	HashMap<Object, Object> topLevelAssInfo = new HashMap<>();

	private Map<String, AccountVO> accPkMap = new HashMap<>();

	private Map<String, AccountVO> qryAccCodeMap = new HashMap<>();

	private BalanceSubjAssBSVO[] filterOfHasBalanceButNoOccur(BalanceSubjAssBSVO[] vos, GlQueryVO p_qryVO) {
		try {
			if (vos == null || vos.length == 0 || p_qryVO

					.getFormatVO().isShowHasBalanceButZeroOccur())
				return vos;
			Vector<BalanceSubjAssBSVO> result = new Vector();
			for (int i = 0; i < vos.length; i++) {
				if ((vos[i].getValue(11) != null && !vos[i].getValue(11).equals(ZeroUFdoubleConstant.DFDB_ZERO))
						|| (vos[i].getValue(12) != null && !vos[i].getValue(12).equals(ZeroUFdoubleConstant.DFDB_ZERO))
						|| (vos[i].getValue(13) != null && !vos[i].getValue(13).equals(ZeroUFdoubleConstant.DFDB_ZERO))
						|| (vos[i].getValue(14) != null && !vos[i].getValue(14).equals(ZeroUFdoubleConstant.DFDB_ZERO))
						|| (vos[i].getValue(15) != null && !vos[i].getValue(15).equals(ZeroUFdoubleConstant.DFDB_ZERO))
						|| (vos[i].getValue(16) != null && !vos[i].getValue(16).equals(ZeroUFdoubleConstant.DFDB_ZERO))
						|| (vos[i].getValue(17) != null && !vos[i].getValue(17).equals(ZeroUFdoubleConstant.DFDB_ZERO))
						|| (vos[i].getValue(18) != null && !vos[i].getValue(18).equals(ZeroUFdoubleConstant.DFDB_ZERO)))
					result.addElement(vos[i]);
			}
			vos = new BalanceSubjAssBSVO[result.size()];
			result.copyInto((Object[]) vos);
		} catch (Exception exception) {
		}
		return vos;
	}

	private BalanceSubjAssBSVO[] addSumAllMark(BalanceSubjAssBSVO[] p_vos) throws Exception {
		if (p_vos == null || p_vos.length == 0)
			return null;
		int iSumAllIndex = p_vos.length - 1;
		p_vos[iSumAllIndex].setValue(90,
				NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000115"));
		p_vos[iSumAllIndex].setValue(46, "");
		p_vos[iSumAllIndex].setValue(104, "");
		p_vos[iSumAllIndex].setValue(102, "9999");
		p_vos[iSumAllIndex].setValue(49, "99999999999999999999");
		p_vos[iSumAllIndex].setValue(2, "");
		p_vos[iSumAllIndex].setValue(0, "");
		p_vos[iSumAllIndex].setValue(48, "true");
		p_vos[iSumAllIndex].setValue(35, null);
		p_vos[iSumAllIndex].setValue(36, null);
		if (this.m_qryVO.getCurrTypeName()
				.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000116"))) {
			p_vos[iSumAllIndex].setValue(4, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(8, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(12, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(16, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(20, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(24, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(28, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(32, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(61, ZeroUFdoubleConstant.DFDB_ZERO);
			p_vos[iSumAllIndex].setValue(65, ZeroUFdoubleConstant.DFDB_ZERO);
		}
		String tempyear = this.m_qryVO.getYear();
		String tempendyear = this.m_qryVO.getEndYear();
		if (!tempyear.equals(tempendyear)) {
			for (int i = 0; i < p_vos.length; i++) {
				if (p_vos[i].getValue(90) != null) {
					p_vos[i].setValue(3, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(4, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(5, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(6, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(7, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(8, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(9, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(10, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(27, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(28, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(29, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(30, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(31, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(32, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(33, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(34, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(35, null);
					p_vos[i].setValue(36, null);
					p_vos[i].setValue(60, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(61, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(62, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(63, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(64, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(65, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(66, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(67, ZeroUFdoubleConstant.DFDB_ZERO);
				}
			}
		} else {
			for (int i = 0; i < p_vos.length; i++) {
				if (this.m_qryVO.getCurrTypeName()
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000116"))
						&& p_vos[i].getValue(90) != null && p_vos[i].getValue(90).equals(
								NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000117"))) {
					p_vos[i].setValue(49, "99999999999999999998");
					p_vos[i].setValue(2, "");
				}
				if (p_vos[i].getValue(90) != null && p_vos[i].getValue(90)
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000471")))
					p_vos[i].setValue(2, "");
				if (this.m_qryVO.getCurrTypeName()
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000116"))
						&& p_vos[i].getValue(90) != null && p_vos[i].getValue(90).equals(
								NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000471"))) {
					p_vos[i].setValue(4, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(8, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(12, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(16, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(20, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(24, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(28, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(32, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(61, ZeroUFdoubleConstant.DFDB_ZERO);
					p_vos[i].setValue(65, ZeroUFdoubleConstant.DFDB_ZERO);
				}
			}
		}
		return p_vos;
	}

	private BalanceSubjAssBSVO[] adjustAccInfo(BalanceSubjAssBSVO[] param) throws Exception {
		if (param != null && param.length != 0) {
			String[] orgBookPks = this.m_qryVO.getpk_accountingbook();
			Object[] accSubjCodesPerCorp = new Object[orgBookPks.length];
			for (int i = 0; i < accSubjCodesPerCorp.length; i++) {
				Vector<String> vCorpPlusAccsubj = new Vector();
				for (int k = 0; k < param.length; k++) {
					if (param[k].getValue(102).toString().equals(orgBookPks[i]) && param[k]

							.getValue(45) != null &&

							!param[k].getValue(45).toString().trim().equals("")
							&& !vCorpPlusAccsubj.contains(param[k].getValue(45).toString()))
						vCorpPlusAccsubj.addElement(param[k].getValue(45)

								.toString());
				}
				accSubjCodesPerCorp[i] = vCorpPlusAccsubj;
			}
			Vector<AccountVO> vAccsubjVO = new Vector();
			for (int j = 0; j < accSubjCodesPerCorp.length; j++) {
				if (((Vector) accSubjCodesPerCorp[j]).size() != 0) {
					String[] accCodes = new String[((Vector) accSubjCodesPerCorp[j]).size()];
					((Vector) accSubjCodesPerCorp[j]).copyInto((Object[]) accCodes);
					AccountVO[] AccsubjVOs = AccountUtilGL.queryAccountVosByCodes(orgBookPks[j], accCodes,
							this.m_qryVO.getSubjVersion());
					for (int k = 0; k < AccsubjVOs.length; k++)
						vAccsubjVO.addElement(AccsubjVOs[k]);
				}
			}
			return param;
		}
		return null;
	}

	private BalanceSubjAssBSVO[] adjustAssOrder(BalanceSubjAssBSVO[] p_vos) throws Exception {
		if (p_vos == null || p_vos.length == 0)
			return null;
		AssVO[] assVosOri = this.m_qryVO.getAssVos();
		for (int i = 0; i < p_vos.length; i++) {
			AssVO[] assVosTmp = new AssVO[(p_vos[i].getAssVOs()).length];
			for (int j = 0; j < (p_vos[i].getAssVOs()).length; j++) {
				for (int k = 0; k < (p_vos[i].getAssVOs()).length; k++) {
					if (p_vos[i].getAssVOs()[j].getPk_Checktype().equals(assVosOri[k].getPk_Checktype()))
						assVosTmp[k] = p_vos[i].getAssVOs()[j];
				}
			}
			p_vos[i].setValue(0, assVosTmp);
		}
		return p_vos;
	}

	private BalanceSubjAssBSVO[] adjustContent(BalanceSubjAssBSVO[] p_vos) throws Exception {
		if (p_vos == null || p_vos.length == 0)
			return null;
		Vector<BalanceSubjAssBSVO> tmp = new Vector();
		Vector vSumEle = getSumEle();
		String sMark = null;
		int[] sortIndexTemp = getSortIndex(1);
		GlQueryVO tempqvo = (GlQueryVO) this.m_qryVO.clone();
		AssAttQueryTool.suplyCurrentGlQueryVOForResult(tempqvo);
		AssVO[] assVosTemp = tempqvo.getAssVos();
		for (int j = 0; j < p_vos.length; j++) {
			sMark = (String) p_vos[j].getValue(90);
			int iIndexTemp = -1;
			if (sMark != null
					&& !sMark.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000115")))
				if (sMark.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000117"))) {
					iIndexTemp = 43;
					p_vos[j].setValue(49, "99999999999999999998");
				} else if (sMark
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000119"))) {
					iIndexTemp = 49;
				} else if (sMark.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000471"))
						|| sMark.equals(
								NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000120"))) {
					iIndexTemp = 102;
				} else if (sMark
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000121"))) {
					iIndexTemp = 46;
				} else {
					for (int k = 0; k < assVosTemp.length; k++) {
						String assSmark = sMark.substring(0, sMark.indexOf(
								NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000122")));
						if (assSmark.equals(assVosTemp[k].getChecktypename())) {
							if (k == 0) {
								iIndexTemp = 80;
								break;
							}
							if (k == 1) {
								iIndexTemp = 81;
								break;
							}
							if (k == 2) {
								iIndexTemp = 87;
								break;
							}
							if (k == 3) {
								iIndexTemp = 83;
								break;
							}
							if (k == 4) {
								iIndexTemp = 93;
								break;
							}
							if (k == 5) {
								iIndexTemp = 94;
								break;
							}
							if (k == 6) {
								iIndexTemp = 95;
								break;
							}
							if (k == 7) {
								iIndexTemp = 96;
								break;
							}
							if (k == 8) {
								iIndexTemp = 92;
								break;
							}
						}
					}
				}
			if (iIndexTemp != -1)
				for (int k = 0; k < sortIndexTemp.length; k++) {
					if (k != sortIndexTemp.length - 1 && sortIndexTemp[k] == iIndexTemp)
						for (int m = k + 1; m < sortIndexTemp.length; m++)
							p_vos[j].setValue(sortIndexTemp[m], "");
				}
			if (sMark == null
					|| sMark.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000115"))
					|| vSumEle.contains(sMark))
				tmp.addElement(p_vos[j]);
		}
		if (tmp.size() == 0) {
			p_vos = null;
		} else {
			p_vos = new BalanceSubjAssBSVO[tmp.size()];
			tmp.copyInto((Object[]) p_vos);
		}
		for (int i = 0; i < p_vos.length; i++) {
			if (this.m_qryVO.getCurrTypeName().equals(CurrTypeConst.ALL_CURRTYPE()) && p_vos[i].getValue(90) != null
					&& p_vos[i].getValue(90)
							.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000471")))
				p_vos[i].setValue(2, "");
			sMark = (String) p_vos[i].getValue(90);
			if (sMark != null
					&& !sMark.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000115"))) {
				if (p_vos[i].getAss0InnerCode() != null && p_vos[i].getAss0InnerCode().equals("")) {
					p_vos[i].getAssVOs()[0].setCheckvaluecode("");
					p_vos[i].getAssVOs()[0].setCheckvaluename("");
				}
				if (p_vos[i].getAss1InnerCode() != null && p_vos[i].getAss1InnerCode().equals("")) {
					p_vos[i].getAssVOs()[1].setCheckvaluecode("");
					p_vos[i].getAssVOs()[1].setCheckvaluename("");
				}
				if (p_vos[i].getAss2InnerCode() != null && p_vos[i].getAss2InnerCode().equals("")) {
					p_vos[i].getAssVOs()[2].setCheckvaluecode("");
					p_vos[i].getAssVOs()[2].setCheckvaluename("");
				}
				if (p_vos[i].getAss3InnerCode() != null && p_vos[i].getAss3InnerCode().equals("")) {
					p_vos[i].getAssVOs()[3].setCheckvaluecode("");
					p_vos[i].getAssVOs()[3].setCheckvaluename("");
				}
				if (p_vos[i].getAss4InnerCode() != null && p_vos[i].getAss4InnerCode().equals("")) {
					p_vos[i].getAssVOs()[4].setCheckvaluecode("");
					p_vos[i].getAssVOs()[4].setCheckvaluename("");
				}
				if (p_vos[i].getAss5InnerCode() != null && p_vos[i].getAss5InnerCode().equals("")) {
					p_vos[i].getAssVOs()[5].setCheckvaluecode("");
					p_vos[i].getAssVOs()[5].setCheckvaluename("");
				}
				if (p_vos[i].getAss6InnerCode() != null && p_vos[i].getAss6InnerCode().equals("")) {
					p_vos[i].getAssVOs()[6].setCheckvaluecode("");
					p_vos[i].getAssVOs()[6].setCheckvaluename("");
				}
				if (p_vos[i].getAss7InnerCode() != null && p_vos[i].getAss7InnerCode().equals("")) {
					p_vos[i].getAssVOs()[7].setCheckvaluecode("");
					p_vos[i].getAssVOs()[7].setCheckvaluename("");
				}
				if (p_vos[i].getAss8InnerCode() != null && p_vos[i].getAss8InnerCode().equals("")) {
					p_vos[i].getAssVOs()[8].setCheckvaluecode("");
					p_vos[i].getAssVOs()[8].setCheckvaluename("");
				}
			}
		}
		return p_vos;
	}

	private BalanceSubjAssBSVO[] adjustOrgBookInfo(BalanceSubjAssBSVO[] param) throws Exception {
		if (this.m_qryVO.isMultiCorpCombine() || (this.m_qryVO.getpk_accountingbook()).length == 1) {
			if (param != null && param.length != 0)
				for (int i = 0; i < param.length; i++)
					param[i].setValue(102, this.m_qryVO.getBaseAccountingbook());
			return param;
		}
		if (param != null && param.length != 0) {
			AccountingBookVO[] glorgbookvos = AccountBookUtil
					.getGlOrgBookVOByPrimaryKeys(this.m_qryVO.getpk_accountingbook());
			for (int i = 0; i < param.length; i++) {
				if (param[i].getValue(102) != null &&

						!param[i].getValue(102).toString().trim().equals("")) {
					String sPkGlorgbook = param[i].getValue(102).toString();
					try {
						for (int j = 0; j < glorgbookvos.length; j++) {
							if (sPkGlorgbook.equals(glorgbookvos[j].getPrimaryKey())) {
								param[i].setValue(104, glorgbookvos[j].getName());
								break;
							}
						}
					} catch (NullPointerException e) {
						param[i].setValue(104,
								NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000123"));
					}
				}
			}
			return param;
		}
		return null;
	}

	private BalanceSubjAssBSVO[] adjustCurrType(BalanceSubjAssBSVO[] vos) throws Exception {
		if (vos == null || vos.length == 0)
			return vos;
		String currtypename = this.m_qryVO.getCurrTypeName();
		if (currtypename.equals(CurrTypeConst.ALL_CURRTYPE())) {
			CurrtypeVO[] currVOs = CurrtypeGL.queryAll(null);
			for (int i = 0; i < vos.length; i++) {
				if (vos[i].getValue(90) == null || (

				!vos[i].getValue(90)
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000117")) &&

						!vos[i].getValue(90)
								.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000115"))
						&&

						!vos[i].getValue(90)
								.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000471"))
						&& vos[i].getValue(49) != null))
					for (int j = 0; j < currVOs.length; j++) {
						if (vos[i].getValue(49).equals(currVOs[j].getPk_currtype())) {
							vos[i].setValue(2, GLMultiLangUtil.getMultiName(currVOs[j]));
							break;
						}
					}
			}
		}
		return vos;
	}

	private BalanceSubjAssBSVO[] appendAccInfo(BalanceSubjAssBSVO[] param, GlQueryVO p_qryVO) throws Exception {
		if (param != null && param.length != 0) {
			for (int i = 0; i < param.length; i++) {
				String sAcc = param[i].getValue(42).toString();
				AccountVO aAccsubjVO = this.accPkMap.get(sAcc);
				if (aAccsubjVO != null) {
					param[i].setValue(47, aAccsubjVO.getBalanorient());
					param[i].setValue(48, aAccsubjVO.getBothorient());
					param[i].setValue(45, aAccsubjVO.getCode());
					param[i].setValue(46, GLMultiLangUtil.getMultiDispName(aAccsubjVO));
				}
			}
			return param;
		}
		return null;
	}

	private BalanceSubjAssBSVO[] appendAccumVOs(BalanceSubjAssBSVO[] bsvos, GlBalanceVO[] glvos, int returnCurrtype)
			throws Exception {
		VoWizard wizard = new VoWizard();
		CVoSortTool sortTool = new CVoSortTool();
		sortTool.setGetSortTool(this);
		wizard.setSortTool(sortTool);
		if (glvos != null && glvos.length != 0) {
			int[] intIndexBalance = {42, 43, 40, 102, 2};
			int[] intIndexInit = {4, 2, 19, 31, 7};
			wizard.setMatchingIndex(intIndexBalance, intIndexInit);
			wizard.setAppendIndex(
					new int[]{43, 40, 102, 49, 42, 47, 48, 0, 104, 2, 19, 20, 21, 22, 23, 24, 25, 26, 119, 120, 121,
							122},
					new int[]{2, 19, 31, 7, 4, 21, 22, 20, 34, 7, 10, 11, 12,

							GlBalanceKey.getLocDebitKey(returnCurrtype), 14, 15, 16,

							GlBalanceKey.getLocCreditKey(returnCurrtype), 44, 45, 46, 47});
			wizard.setLeftClass(BalanceSubjAssBSVO.class);
			IVoAccess[] arrayOfIVoAccess = wizard.concat((IVoAccess[]) bsvos, (IVoAccess[]) glvos, true);
			bsvos = new BalanceSubjAssBSVO[arrayOfIVoAccess.length];
			System.arraycopy(arrayOfIVoAccess, 0, bsvos, 0, arrayOfIVoAccess.length);
		}
		return bsvos;
	}

	private BalanceSubjAssBSVO[] appendAssInfo(BalanceSubjAssBSVO[] param, GlQueryVO p_qryVO) throws Exception {
		if (param != null && param.length != 0) {
			GlAssDeal objTemp = new GlAssDeal();
			String[] strType = null;
			AssVO[] assvos = p_qryVO.getAssVos();
			if (assvos != null && assvos.length != 0) {
				strType = new String[assvos.length];
				for (int j = 0; j < assvos.length; j++)
					strType[j] = assvos[j].getPk_Checktype();
			}
			objTemp.setMatchingIndex(40);
			objTemp.setAppendIndex(0);
			objTemp.dealWith((IVoAccess[]) param, strType);
			param = adjustAssOrder(param);
			param = adjustAssvos(param, p_qryVO);
			param = adjustAllAssOrder(param);
			Vector<BalanceSubjAssBSVO> vMultiCorp = new Vector();
			Vector<BalanceSubjAssBSVO> vTemp1 = new Vector();
			if (!p_qryVO.getFormatVO().isMultiCorpCombine() && (p_qryVO.getpk_accountingbook()).length > 1) {
				for (int j = 0; j < (p_qryVO.getpk_accountingbook()).length; j++) {
					for (int k = 0; k < param.length; k++) {
						if (param[k].getPk_glorgbook().equals(p_qryVO.getpk_accountingbook()[j]))
							vTemp1.addElement(param[k]);
					}
					if (vTemp1.size() >= 1) {
						BalanceSubjAssBSVO[] bsVosTemp = new BalanceSubjAssBSVO[vTemp1.size()];
						vTemp1.copyInto((Object[]) bsVosTemp);
						CBalanceAssAttTool.buildAssInnerCode(bsVosTemp, getPk_corp(p_qryVO.getpk_accountingbook()[j]),
								0);
						for (int m = 0; m < bsVosTemp.length; m++)
							vMultiCorp.addElement(bsVosTemp[m]);
						vTemp1.removeAllElements();
					}
				}
				vMultiCorp.copyInto((Object[]) param);
			} else {
				CBalanceAssAttTool.buildAssInnerCode(param, getPk_corp(p_qryVO.getBaseAccountingbook()), 0);
			}
			if (!p_qryVO.getFormatVO().isIsAssIncldFatherSon())
				if (!this.topLevelAssInfo.isEmpty())
					for (int j = 0; j < param.length; j++) {
						AssVO[] ass = (AssVO[]) param[j].getValue(0);
						for (int k = 0; k < ass.length; k++) {
							String tempKey = ass[k].getPk_Checktype() + ass[k].getInnerCode();
							boolean flag = false;
							String topKey = null;
							for (int m = 0; m < (this.topLevelAssInfo.keySet().toArray()).length; m++) {
								if (!this.topLevelAssInfo.keySet().toArray()[m].toString().equals(tempKey) && tempKey
										.indexOf(this.topLevelAssInfo.keySet().toArray()[m].toString()) >= 0) {
									flag = true;
									topKey = this.topLevelAssInfo.keySet().toArray()[m].toString();
									break;
								}
							}
							if (flag) {
								ass[k] = (AssVO) this.topLevelAssInfo.get(topKey);
								switch (k) {
									case 0 :
										param[j].setValue(80, ass[k].getInnerCode());
										break;
									case 1 :
										param[j].setValue(81, ass[k].getInnerCode());
										break;
									case 2 :
										param[j].setValue(87, ass[k].getInnerCode());
										break;
									case 3 :
										param[j].setValue(83, ass[k].getInnerCode());
										break;
									case 4 :
										param[j].setValue(93, ass[k]

												.getInnerCode());
										break;
									case 5 :
										param[j].setValue(94, ass[k]

												.getInnerCode());
										break;
									case 6 :
										param[j].setValue(95, ass[k]

												.getInnerCode());
										break;
									case 7 :
										param[j].setValue(96, ass[k]

												.getInnerCode());
										break;
									case 8 :
										param[j].setValue(92, ass[k]

												.getInnerCode());
										break;
								}
							}
						}
					}
			param = combineAss(param);
			for (int i = 0; i < param.length; i++) {
				AssVO[] assVos = (AssVO[]) param[i].getValue(0);
				CAssTool.convertNull(assVos, new int[]{2, 5, 6}, "null");
			}
			return param;
		}
		return null;
	}

	private BalanceSubjAssBSVO[] adjustAssvos(BalanceSubjAssBSVO[] param, GlQueryVO p_qryVO) throws Exception {
		GLQueryObj[] qryObjs = p_qryVO.getFormatVO().getQryObjs();
		AssVO[] condAssvos = p_qryVO.getAssVos();
		ArrayList<AttrsValueVO[]> attrsVOList = (ArrayList) new ArrayList<>();
		ArrayList<String> attrTypeList = new ArrayList<>();
		ArrayList<BDAttributeDescInfo[]> bdAttrDescList = (ArrayList) new ArrayList<>();
		AssVO[] resultAssvos = null;
		HashMap<String, String> attrToAss = new HashMap<>();
		int attrAssNum = 0;
		AttrsValueVO[] attrsVOsTemp = null;
		for (int i = 0; i < qryObjs.length; i++) {
			attrsVOsTemp = qryObjs[i].getAttrsValues();
			if (attrsVOsTemp != null) {
				attrsVOList.add(attrsVOsTemp);
				attrTypeList.add(qryObjs[i].getType());
				for (int k = 0; k < condAssvos.length; k++) {
					if (condAssvos[k].getPk_Checktype().equals(qryObjs[i].getAttrsValues()[0].getPkAssDoc())) {
						attrToAss.put(String.valueOf(attrAssNum), String.valueOf(k));
						break;
					}
				}
				attrAssNum++;
				BDAttributeDescInfo[] attribInfos = new BDAttributeDescInfo[attrsVOsTemp.length];
				for (int m = 0; m < attrsVOsTemp.length; m++)
					attribInfos[m] = AssAttriVODealTool.changeAttrsVOToBDAttrDescInfo(attrsVOsTemp[m]);
				bdAttrDescList.add(attribInfos);
			}
		}
		String[][] docPksOfDataVOs = new String[attrsVOList.size()][param.length];
		for (int j = 0; j < param.length; j++) {
			resultAssvos = param[j].getAssVOs();
			int k = 0;
			while (k < attrsVOList.size()) {
				int posOfAss = Integer.valueOf(attrToAss.get(String.valueOf(k))).intValue();
				docPksOfDataVOs[k][j] = resultAssvos[posOfAss].getPk_Checkvalue();
				k++;
			}
		}
		removeAssvosCausedbyAttr(condAssvos, param);
		Iterator<AttrsValueVO[]> iter = (Iterator) attrsVOList.iterator();
		int n = 0;
		String pk_corp = AccountBookUtil.getPk_org(p_qryVO.getBaseAccountingbook());
		while (iter.hasNext()) {
			AttrsValueVO[] nthAttrsVos = iter.next();
			Map<String, Object[]> docPK_ValuesMap = null;
			docPK_ValuesMap = (Map<String, Object[]>) AssAttributesConst.getAttrByDocID(pk_corp, docPksOfDataVOs[n],
					nthAttrsVos);
			for (int k = 0; k < param.length; k++) {
				Object[] docAttrValues = docPK_ValuesMap.get(docPksOfDataVOs[n][k]);
				addAttrAssvo(pk_corp, param[k], docAttrValues, nthAttrsVos, attrTypeList.get(n));
			}
			n++;
		}
		return param;
	}

	private void removeAssvosCausedbyAttr(AssVO[] condAssvos, BalanceSubjAssBSVO[] param) {
		ArrayList<AssVO> assvoList = new ArrayList<>();
		for (int j = 0; j < param.length; j++) {
			assvoList.clear();
			for (int i = 0; i < condAssvos.length; i++) {
				if (condAssvos[i].getnote1() == null || !condAssvos[i].getnote1().equals("attribute"))
					assvoList.add(param[j].getAssVOs()[i]);
			}
			if (assvoList.size() > 0) {
				AssVO[] newAssvo = new AssVO[assvoList.size()];
				assvoList.toArray(newAssvo);
				param[j].setValue(0, newAssvo);
			} else {
				param[j].setValue(0, new AssVO[0]);
			}
		}
	}

	private void addAttrAssvo(String pkCorp, BalanceSubjAssBSVO param, Object[] docAttrValues,
			AttrsValueVO[] nthAttrsVos, String attrType) {
		ArrayList<AssVO> assvoList = new ArrayList<>();
		int i;
		for (i = 0; i < (param.getAssVOs()).length; i++)
			assvoList.add(param.getAssVOs()[i]);
		for (i = 0; i < nthAttrsVos.length; i++) {
			AssVO attrAssvo = AssAttriVODealTool.getAssvoByAttr(pkCorp, docAttrValues[i], nthAttrsVos[i], attrType);
			assvoList.add(attrAssvo);
		}
		if (assvoList.size() > 0) {
			AssVO[] newAssvo = new AssVO[assvoList.size()];
			assvoList.toArray(newAssvo);
			param.setValue(0, newAssvo);
		}
	}

	private BalanceSubjAssBSVO[] adjustAllAssOrder(BalanceSubjAssBSVO[] p_vos) throws Exception {
		GLQueryObj[] qryObjs = this.m_qryVO.getFormatVO().getQryObjs();
		for (int i = 0; i < p_vos.length; i++) {
			AssVO[] assVosTmp = new AssVO[(p_vos[i].getAssVOs()).length];
			int n = 0;
			for (int j = 0; j < qryObjs.length; j++) {
				if (!qryObjs[j].getType()
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000031"))) {
					if (qryObjs[j].getValueRange() != null && (qryObjs[j].getValueRange()).length > 0)
						for (int k = 0; k < (p_vos[i].getAssVOs()).length; k++) {
							if (p_vos[i].getAssVOs()[k].getPk_Checktype()
									.equals(qryObjs[j].getValueRange()[0].getPk_Checktype())) {
								assVosTmp[n++] = p_vos[i].getAssVOs()[k];
								break;
							}
						}
					if (qryObjs[j].getAttrsValues() != null && (qryObjs[j].getAttrsValues()).length > 0)
						for (int index = 0; index < (qryObjs[j].getAttrsValues()).length; index++) {
							for (int k = 0; k < (p_vos[i].getAssVOs()).length; k++) {
								String pk_checkType = null;
								if (qryObjs[j].getAttrsValues()[index].getArrtibute() instanceof Attribute) {
									pk_checkType = ((Attribute) qryObjs[j].getAttrsValues()[index].getArrtibute())
											.getDataTypeID();
								} else {
									pk_checkType = ((UserdefAttributeAdapter) qryObjs[j].getAttrsValues()[index]
											.getArrtibute()).getDataType().getID();
								}
								if (p_vos[i].getAssVOs()[k].getUserData() != null
										&& p_vos[i].getAssVOs()[k].getUserData().equals("attribute")
										&& (p_vos[i].getAssVOs()[k].getPk_Checktype().equals(pk_checkType)
												|| (p_vos[i].getAssVOs()[k].getPk_Checktype().equals("null")
														&& p_vos[i].getAssVOs()[k].getChecktypename()
																.equals(qryObjs[j].getAttrsValues()[index].getName()
																		+ "(" + qryObjs[j].getType() + ")")))) {
									assVosTmp[n++] = p_vos[i].getAssVOs()[k];
									break;
								}
							}
						}
				}
			}
			p_vos[i].setValue(0, assVosTmp);
		}
		return p_vos;
	}

	private BalanceSubjAssBSVO[] appendInitVOs(BalanceSubjAssBSVO[] bsvos, GlBalanceVO[] glvos, int returnCurrtype)
			throws Exception {
		try {
			VoWizard wizard = new VoWizard();
			CVoSortTool sortTool = new CVoSortTool();
			sortTool.setGetSortTool(this);
			wizard.setSortTool(sortTool);
			if (glvos != null && glvos.length != 0) {
				int[] intIndexBalance = {42, 43, 40, 102, 2};
				int[] intIndexInit = {4, 2, 19, 31, 7};
				wizard.setMatchingIndex(intIndexBalance, intIndexInit);
				wizard.setAppendIndex(
						new int[]{43, 40, 102, 49, 42, 47, 48, 0, 104, 2, 3, 4, 5, 6, 7, 8, 9, 10, 111, 112, 113, 114},
						new int[]{2, 19, 31, 7, 4, 21, 22, 20, 34, 7, 10, 11, 12,

								GlBalanceKey.getLocDebitKey(returnCurrtype), 14, 15, 16,

								GlBalanceKey.getLocCreditKey(returnCurrtype), 44, 45, 46, 47});
				wizard.setLeftClass(BalanceSubjAssBSVO.class);
				IVoAccess[] arrayOfIVoAccess = wizard.concat((IVoAccess[]) bsvos, (IVoAccess[]) glvos, true);
				bsvos = new BalanceSubjAssBSVO[arrayOfIVoAccess.length];
				System.arraycopy(arrayOfIVoAccess, 0, bsvos, 0, arrayOfIVoAccess.length);
			}
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
		}
		return bsvos;
	}

	private BalanceSubjAssBSVO[] appendOccurVOs(BalanceSubjAssBSVO[] bsvos, GlBalanceVO[] glvos, int returnCurrtype)
			throws Exception {
		VoWizard wizard = new VoWizard();
		CVoSortTool sortTool = new CVoSortTool();
		sortTool.setGetSortTool(this);
		wizard.setSortTool(sortTool);
		if (glvos != null && glvos.length != 0) {
			int[] intIndexBalance = {42, 43, 40, 102, 2};
			int[] intIndexInit = {4, 2, 19, 31, 7};
			wizard.setMatchingIndex(intIndexBalance, intIndexInit);
			wizard.setAppendIndex(
					new int[]{43, 40, 102, 49, 42, 47, 48, 0, 104, 2, 11, 12, 13, 14, 15, 16, 17, 18, 115, 116, 117,
							118},
					new int[]{2, 19, 31, 7, 4, 21, 22, 20, 34, 7, 10, 11, 12,

							GlBalanceKey.getLocDebitKey(returnCurrtype), 14, 15, 16,

							GlBalanceKey.getLocCreditKey(returnCurrtype), 44, 45, 46, 47});
			wizard.setLeftClass(BalanceSubjAssBSVO.class);
			IVoAccess[] arrayOfIVoAccess = wizard.concat((IVoAccess[]) bsvos, (IVoAccess[]) glvos, true);
			bsvos = new BalanceSubjAssBSVO[arrayOfIVoAccess.length];
			System.arraycopy(arrayOfIVoAccess, 0, bsvos, 0, arrayOfIVoAccess.length);
		}
		return bsvos;
	}

	private BalanceSubjAssBSVO[] changeAccInfo(BalanceSubjAssBSVO[] param) throws Exception {
		if (param == null || param.length == 0)
			return null;
		AccountVO[] AccsubjVOs = (AccountVO[]) this.qryAccCodeMap.values().toArray((Object[]) new AccountVO[0]);
		for (int i = 0; i < param.length; i++) {
			String sAcc = param[i].getValue(45).toString();
			AccountVO aAccsubjVO = null;
			for (int j = 0; j < AccsubjVOs.length; j++) {
				if (sAcc.startsWith(AccsubjVOs[j].getCode())) {
					aAccsubjVO = AccsubjVOs[j];
					break;
				}
			}
			param[i].setValue(42, aAccsubjVO.getPk_accasoa());
			param[i].setValue(47, aAccsubjVO.getBalanorient());
			param[i].setValue(48, aAccsubjVO.getBothorient());
			param[i].setValue(45, aAccsubjVO.getCode());
			param[i].setValue(46, GLMultiLangUtil.getMultiDispName(aAccsubjVO));
		}
		return param;
	}

	private BalanceSubjAssBSVO[] changeAccInfoFaS(BalanceSubjAssBSVO[] param) throws Exception {
		if (param == null || param.length == 0)
			return null;
		Vector<BalanceSubjAssBSVO> vSubjAssBS = new Vector();
		AccountVO[] vAccsubjVO = (AccountVO[]) this.qryAccCodeMap.values().toArray((Object[]) new AccountVO[0]);
		BalanceSubjAssBSVO[] vos = new BalanceSubjAssBSVO[vAccsubjVO.length];
		for (int i = 0; i < param.length; i++) {
			if (param[i].getValue(90) != null) {
				for (int j = 0; j < vos.length; j++) {
					if (vos[j] != null) {
						vSubjAssBS.addElement(vos[j]);
						vos[j] = null;
					}
				}
				vSubjAssBS.addElement(param[i]);
			} else if (i > 0 && !param[i].getPk_glorgbook().equals(param[i - 1].getPk_glorgbook())) {
				for (int j = 0; j < vos.length; j++) {
					if (vos[j] != null) {
						vSubjAssBS.addElement(vos[j]);
						vos[j] = null;
					}
				}
				String sAcc = param[i].getValue(45).toString();
				for (int k = 0; k < vAccsubjVO.length; k++) {
					if (sAcc.startsWith(vAccsubjVO[k].getCode())) {
						AccountVO aAccsubjVO = vAccsubjVO[k];
						if (vos[k] == null) {
							vos[k] = (BalanceSubjAssBSVO) param[i].clone();
							vos[k].setValue(42, aAccsubjVO.getPk_accasoa());
							vos[k].setValue(47, aAccsubjVO.getBalanorient());
							vos[k].setValue(48, aAccsubjVO.getBothorient());
							vos[k].setValue(45, aAccsubjVO.getCode());
							vos[k].setValue(46, GLMultiLangUtil.getMultiDispName(aAccsubjVO));
						} else {
							BalanceSubjAssBSVO tempVo = (BalanceSubjAssBSVO) param[i].clone();
							tempVo.setValue(42, aAccsubjVO.getPk_accasoa());
							tempVo.setValue(47, aAccsubjVO.getBalanorient());
							tempVo.setValue(48, aAccsubjVO.getBothorient());
							tempVo.setValue(45, aAccsubjVO.getCode());
							tempVo.setValue(46, GLMultiLangUtil.getMultiDispName(aAccsubjVO));
							BalanceSubjAssBSVO[] tempVos = new BalanceSubjAssBSVO[2];
							tempVos[0] = vos[k];
							tempVos[1] = tempVo;
							vos[k] = combineAcc(tempVos)[0];
						}
					}
				}
			} else {
				String sAcc = param[i].getValue(45).toString();
				for (int j = 0; j < vAccsubjVO.length; j++) {
					if (sAcc.startsWith(vAccsubjVO[j].getCode())) {
						AccountVO aAccsubjVO = vAccsubjVO[j];
						if (vos[j] == null) {
							vos[j] = (BalanceSubjAssBSVO) param[i].clone();
							vos[j].setValue(42, aAccsubjVO.getPk_accasoa());
							vos[j].setValue(47, aAccsubjVO.getBalanorient());
							vos[j].setValue(48, aAccsubjVO.getBothorient());
							vos[j].setValue(45, aAccsubjVO.getCode());
							vos[j].setValue(46, GLMultiLangUtil.getMultiDispName(aAccsubjVO));
						} else {
							BalanceSubjAssBSVO tempVo = (BalanceSubjAssBSVO) param[i].clone();
							tempVo.setValue(42, aAccsubjVO.getPk_accasoa());
							tempVo.setValue(47, aAccsubjVO.getBalanorient());
							tempVo.setValue(48, aAccsubjVO.getBothorient());
							tempVo.setValue(45, aAccsubjVO.getCode());
							tempVo.setValue(46, GLMultiLangUtil.getMultiDispName(aAccsubjVO));
							BalanceSubjAssBSVO[] tempVos = new BalanceSubjAssBSVO[2];
							tempVos[0] = vos[j];
							tempVos[1] = tempVo;
							vos[j] = combineAcc(tempVos)[0];
						}
					}
				}
			}
		}
		BalanceSubjAssBSVO[] newVOs = new BalanceSubjAssBSVO[vSubjAssBS.size()];
		vSubjAssBS.copyInto((Object[]) newVOs);
		return newVOs;
	}

	private BalanceSubjAssBSVO[] changeAssInfoFaS(BalanceSubjAssBSVO[] param, GlQueryVO p_qryVO) throws Exception {
		if (param == null || param.length == 0)
			return null;
		String pk_Corp = getPk_corp(p_qryVO.getBaseAccountingbook());
		Vector<BalanceSubjAssBSVO> vSubjAssBS = new Vector();
		String strAssPks = null;
		String strAssCodes = null;
		String strAssNames = null;
		GLQueryObj[] glQryObjs = p_qryVO.getFormatVO().getQryObjs();
		AssVO[] qryAssVos = null;
		boolean isAttr = false;
		AssVO aVo = null;
		int iAssIn = 0;
		for (int i = 0; i < glQryObjs.length; i++) {
			if (glQryObjs[i].getIncludeSub()) {
				if (!glQryObjs[i].getType().endsWith(AssAttributesConst.getAttrTirmStr())) {
					aVo = (AssVO) glQryObjs[i].getValueRange()[0].clone();
					strAssPks = glQryObjs[i].getValueRange()[0].getPk_Checkvalue();
					strAssCodes = glQryObjs[i].getValueRange()[0].getCheckvaluecode();
					strAssNames = glQryObjs[i].getValueRange()[0].getCheckvaluename();
					break;
				}
				isAttr = true;
				int pos = AssAttQueryTool.getHasLevelAttrPosFromQryObj(glQryObjs[i], pk_Corp);
				iAssIn += pos;
				qryAssVos = (AssVO[]) glQryObjs[i].getAttrsValues()[pos].getAttrValues();
				break;
			}
			if (!glQryObjs[i].getType()
					.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000031"))
					&& !glQryObjs[i].getIncludeSub())
				if (!glQryObjs[i].getType().endsWith(AssAttributesConst.getAttrTirmStr())) {
					iAssIn++;
				} else {
					iAssIn += (glQryObjs[i].getAttrsValues()).length;
				}
		}
		if (!isAttr) {
			Vector<String> vAssPk = new Vector();
			Vector<String> vAssCode = new Vector();
			Vector<String> vAssName = new Vector();
			StringTokenizer pkToken = new StringTokenizer(strAssPks, ",");
			StringTokenizer codeToken = new StringTokenizer(strAssCodes, ",");
			StringTokenizer nameToken = new StringTokenizer(strAssNames, ",");
			while (pkToken.hasMoreTokens())
				vAssPk.add(pkToken.nextToken());
			while (codeToken.hasMoreTokens())
				vAssCode.add(codeToken.nextToken());
			while (nameToken.hasMoreTokens())
				vAssName.add(nameToken.nextToken());
			qryAssVos = new AssVO[vAssCode.size()];
			for (int m = 0; m < vAssCode.size(); m++) {
				qryAssVos[m] = (AssVO) aVo.clone();
				qryAssVos[m].setPk_Checkvalue(vAssPk.elementAt(m).toString());
				qryAssVos[m].setCheckvaluecode(vAssCode.elementAt(m).toString());
				qryAssVos[m].setCheckvaluename(vAssName.elementAt(m).toString());
			}
		}
		AssVO[][] subVos = new AssVO[qryAssVos.length][];
		for (int j = 0; j < qryAssVos.length; j++)
			subVos[j] = CBalanceAssAttTool.getMeAndSubDocsTackle(qryAssVos[j], pk_Corp);
		BalanceSubjAssBSVO[] vos = new BalanceSubjAssBSVO[qryAssVos.length];
		for (int k = 0; k < param.length; k++) {
			if (param[k].getValue(90) != null) {
				for (int m = 0; m < vos.length; m++) {
					if (vos[m] != null) {
						vSubjAssBS.addElement(vos[m]);
						vos[m] = null;
					}
				}
				vSubjAssBS.addElement(param[k]);
			} else if (k > 0 && !param[k].getPk_glorgbook().equals(param[k - 1].getPk_glorgbook())) {
				for (int m = 0; m < vos.length; m++) {
					if (vos[m] != null) {
						vSubjAssBS.addElement(vos[m]);
						vos[m] = null;
					}
				}
				AssVO aAssVo = ((AssVO[]) param[k].getValue(0))[iAssIn];
				for (int n = 0; n < qryAssVos.length; n++) {
					if (includeInAssvos(aAssVo, subVos[n])) {
						AssVO aAssVoToChange = (AssVO) qryAssVos[n].clone();
						if (vos[n] == null) {
							vos[n] = (BalanceSubjAssBSVO) param[k].clone();
							((AssVO[]) vos[n].getValue(0))[iAssIn] = aAssVoToChange;
						} else {
							BalanceSubjAssBSVO tempVo = (BalanceSubjAssBSVO) param[k].clone();
							((AssVO[]) tempVo.getValue(0))[iAssIn] = aAssVoToChange;
							BalanceSubjAssBSVO[] tempVos = new BalanceSubjAssBSVO[2];
							tempVos[0] = vos[n];
							tempVos[1] = tempVo;
							vos[n] = combineAss1(tempVos)[0];
						}
					}
				}
			} else {
				AssVO aAssVo = ((AssVO[]) param[k].getValue(0))[iAssIn];
				for (int m = 0; m < qryAssVos.length; m++) {
					if (includeInAssvos(aAssVo, subVos[m])) {
						AssVO aAssVoToChange = (AssVO) qryAssVos[m].clone();
						if (vos[m] == null) {
							vos[m] = (BalanceSubjAssBSVO) param[k].clone();
							((AssVO[]) vos[m].getValue(0))[iAssIn] = aAssVoToChange;
						} else {
							BalanceSubjAssBSVO tempVo = (BalanceSubjAssBSVO) param[k].clone();
							((AssVO[]) tempVo.getValue(0))[iAssIn] = aAssVoToChange;
							BalanceSubjAssBSVO[] tempVos = new BalanceSubjAssBSVO[2];
							tempVos[0] = vos[m];
							tempVos[1] = tempVo;
							vos[m] = combineAss1(tempVos)[0];
						}
					}
				}
			}
		}
		BalanceSubjAssBSVO[] newVOs = new BalanceSubjAssBSVO[vSubjAssBS.size()];
		vSubjAssBS.copyInto((Object[]) newVOs);
		adjustAssCode(newVOs);
		return newVOs;
	}

	private void adjustAssCode(BalanceSubjAssBSVO[] newVOs) {
		if (newVOs == null || newVOs.length < 1)
			return;
		try {
			for (int i = 0; i < newVOs.length; i++) {
				AssVO[] ass = (AssVO[]) newVOs[i].getValue(0);
				for (int k = 0; ass != null && k < ass.length; k++) {
					Method method = BalanceSubjAssBSVO.class.getMethod("setAss" + k + "InnerCode",
							new Class[]{String.class});
					method.invoke(newVOs[i], new Object[]{ass[k].getCheckvaluecode()});
					method = BalanceSubjAssBSVO.class.getMethod("setAss" + k + "Property", new Class[]{String.class});
					method.invoke(newVOs[i], new Object[]{ass[k].getChecktypecode()});
				}
			}
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
		}
	}

	private BalanceSubjAssBSVO[] combineAcc(BalanceSubjAssBSVO[] vos) throws Exception {
		if (vos == null || vos.length == 0)
			return vos;
		CIntelVO tt = new CIntelVO();
		int intSumLimit = 0;
		int[] intSortIndex = {45};
		CGenTool genTool = new CGenTool();
		genTool.setLimitSumGen(intSumLimit);
		genTool.setSortIndex(intSortIndex);
		genTool.setGetSortTool(this);
		CUFDoubleSumTool sumTool = new CUFDoubleSumTool();
		int[] sumIndex = {8, 9, 10, 7, 4, 5, 6, 3, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 19, 24, 25, 26, 23, 32,
				33, 34, 31, 28, 29, 30, 27};
		sumTool.setSumIndex(sumIndex);
		COutputTool outputTool = new COutputTool();
		outputTool.setRequireOutputDetail(false);
		outputTool.setSummaryCol(-1);
		CDataSource datasource = new CDataSource();
		Vector<BalanceSubjAssBSVO> vecVos = new Vector();
		for (int i = 0; i < vos.length; i++) {
			vos[i].setUserData(null);
			vecVos.addElement(vos[i]);
		}
		datasource.setSumVector(CDataSource.sortVector(vecVos, (ISortTool) genTool, false));
		try {
			tt.setSumTool((ISumTool) sumTool);
			tt.setGenTool((IGenTool) genTool);
			tt.setDatasource((IDataSource) datasource);
			tt.setOutputTool((IOutputTool) outputTool);
		} catch (Throwable e) {
			Logger.error(e.getMessage(), e);
		}
		Vector recVector = tt.getResultVector();
		BalanceSubjAssBSVO[] newVOs = new BalanceSubjAssBSVO[recVector.size()];
		recVector.copyInto((Object[]) newVOs);
		return newVOs;
	}

	private BalanceSubjAssBSVO[] combineAss(BalanceSubjAssBSVO[] vos) throws Exception {
		int[] intSortIndex;
		if (vos == null || vos.length == 0)
			return vos;
		CIntelVO tt = new CIntelVO();
		int intSumLimit = 1;
		if (this.m_qryVO.getCurrTypeName().equals(CurrTypeConst.ALL_CURRTYPE())) {
			if (this.m_qryVO.isMultiCorpCombine()) {
				intSortIndex = new int[]{43, 45, 49};
				intSumLimit = 2;
			} else {
				intSortIndex = new int[]{43, 45, 102, 49};
				intSumLimit = 3;
			}
		} else if (this.m_qryVO.isMultiCorpCombine()) {
			intSortIndex = new int[]{43, 45};
			intSumLimit = 1;
		} else {
			intSortIndex = new int[]{43, 45, 102};
			intSumLimit = 2;
		}
		int iAssNum = (vos[0] == null) ? 0 : ((vos[0].getAssVOs() == null) ? 0 : (vos[0].getAssVOs()).length);
		int[] iAssSort = null;
		switch (iAssNum) {
			case 1 :
				iAssSort = new int[]{85, 80};
				break;
			case 2 :
				iAssSort = new int[]{85, 80, 86, 81};
				break;
			case 3 :
				iAssSort = new int[]{85, 80, 86, 81, 82, 87};
				break;
			case 4 :
				iAssSort = new int[]{85, 80, 86, 81, 82, 87, 78, 83};
				break;
			case 5 :
				iAssSort = new int[]{85, 80, 86, 81, 82, 87, 78, 83, 79, 93};
				break;
			case 6 :
				iAssSort = new int[]{85, 80, 86, 81, 82, 87, 78, 83, 79, 93, 88, 94};
				break;
			case 7 :
				iAssSort = new int[]{85, 80, 86, 81, 82, 87, 78, 83, 79, 93, 88, 94, 89, 95};
				break;
			case 8 :
				iAssSort = new int[]{85, 80, 86, 81, 82, 87, 78, 83, 79, 93, 88, 94, 89, 95, 91, 96};
				break;
			case 9 :
				iAssSort = new int[]{85, 80, 86, 81, 82, 87, 78, 83, 79, 93, 88, 94, 89, 95, 91, 96, 97, 92};
				break;
		}
		if (iAssSort == null)
			return null;
		int[] intAll = new int[intSortIndex.length + iAssSort.length];
		System.arraycopy(intSortIndex, 0, intAll, 0, intSortIndex.length);
		System.arraycopy(iAssSort, 0, intAll, intSortIndex.length, iAssSort.length);
		intSumLimit += iAssNum * 2;
		CGenTool genTool = new CGenTool();
		genTool.setLimitSumGen(intSumLimit);
		genTool.setSortIndex(intAll);
		genTool.setGetSortTool(this);
		CUFDoubleSumTool sumTool = new CUFDoubleSumTool();
		int[] sumIndex = {8, 9, 10, 7, 4, 5, 6, 3, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 19, 24, 25, 26, 23};
		sumTool.setSumIndex(sumIndex);
		COutputTool outputTool = new COutputTool();
		outputTool.setRequireOutputDetail(false);
		outputTool.setSummaryCol(-1);
		CDataSource datasource = new CDataSource();
		Vector<BalanceSubjAssBSVO> vecVos = new Vector();
		for (int i = 0; i < vos.length; i++) {
			vos[i].setUserData(null);
			vecVos.addElement(vos[i]);
		}
		datasource.setSumVector(CDataSource.sortVector(vecVos, (ISortTool) genTool, false));
		try {
			tt.setSumTool((ISumTool) sumTool);
			tt.setGenTool((IGenTool) genTool);
			tt.setDatasource((IDataSource) datasource);
			tt.setOutputTool((IOutputTool) outputTool);
		} catch (Throwable e) {
			Logger.error(e.getMessage(), e);
		}
		Vector recVector = tt.getResultVector();
		BalanceSubjAssBSVO[] VOs = new BalanceSubjAssBSVO[recVector.size()];
		recVector.copyInto((Object[]) VOs);
		return VOs;
	}

	private BalanceSubjAssBSVO[] combineAss1(BalanceSubjAssBSVO[] vos) throws Exception {
		int[] intSortIndex;
		if (vos == null || vos.length == 0)
			return vos;
		CIntelVO tt = new CIntelVO();
		int intSumLimit = 1;
		if (this.m_qryVO.getCurrTypeName().equals(CurrTypeConst.ALL_CURRTYPE())) {
			if (this.m_qryVO.isMultiCorpCombine()) {
				intSortIndex = new int[]{43, 45, 49};
				intSumLimit = 2;
			} else {
				intSortIndex = new int[]{43, 45, 102, 49};
				intSumLimit = 3;
			}
		} else if (this.m_qryVO.isMultiCorpCombine()) {
			intSortIndex = new int[]{43, 45};
			intSumLimit = 1;
		} else {
			intSortIndex = new int[]{43, 45, 102};
			intSumLimit = 2;
		}
		CGenTool genTool = new CGenTool();
		genTool.setLimitSumGen(intSumLimit);
		genTool.setSortIndex(intSortIndex);
		genTool.setGetSortTool(this);
		CUFDoubleSumTool sumTool = new CUFDoubleSumTool();
		int[] sumIndex = {8, 9, 10, 7, 4, 5, 6, 3, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 19, 24, 25, 26, 23, 32,
				33, 34, 31, 28, 29, 30, 27};
		sumTool.setSumIndex(sumIndex);
		COutputTool outputTool = new COutputTool();
		outputTool.setRequireOutputDetail(false);
		outputTool.setSummaryCol(-1);
		CDataSource datasource = new CDataSource();
		Vector<BalanceSubjAssBSVO> vecVos = new Vector();
		for (int i = 0; i < vos.length; i++) {
			vos[i].setUserData(null);
			vecVos.addElement(vos[i]);
		}
		datasource.setSumVector(CDataSource.sortVector(vecVos, (ISortTool) genTool, false));
		try {
			tt.setSumTool((ISumTool) sumTool);
			tt.setGenTool((IGenTool) genTool);
			tt.setDatasource((IDataSource) datasource);
			tt.setOutputTool((IOutputTool) outputTool);
		} catch (Throwable e) {
			Logger.error(e.getMessage(), e);
		}
		Vector recVector = tt.getResultVector();
		BalanceSubjAssBSVO[] VOs = new BalanceSubjAssBSVO[recVector.size()];
		recVector.copyInto((Object[]) VOs);
		return VOs;
	}

	private BalanceSubjAssBSVO[] compute(BalanceSubjAssBSVO[] vos) throws Exception {
		Vector<BalanceSubjAssBSVO> vecVO = new Vector();
		if (vos == null || vos.length == 0)
			return null;
		Object sCurrPK = null;
		for (int i = 0; i < vos.length; i++) {
			vos[i].setUserData(null);
			sCurrPK = vos[i].getValue(49);
			if (sCurrPK == null)
				vos[i].setValue(49, "**");
			vecVO.addElement(vos[i]);
		}
		CGenTool genTool = new CGenTool();
		int[] intSortIndex = getSortIndex(0);
		int intSumLimit = getLimitSumGen(this.m_qryVO.getCurrTypeName(), this.m_qryVO.getFormatVO().getQryObjs());
		genTool.setSortIndex(intSortIndex);
		genTool.setLimitSumGen(intSumLimit);
		CUFDoubleSumTool sumTool = new CUFDoubleSumTool();
		int[] sumIndex = {8, 9, 10, 7, 4, 5, 6, 3, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 19, 24, 25, 26, 23, 32,
				33, 34, 31, 28, 29, 30, 27};
		sumTool.setSumIndex(sumIndex);
		UFDCBalanceTool balanceTool = new UFDCBalanceTool();
		int[] balanceIndex = {27, 28, 29, 30, 31, 32, 33, 34};
		String[] relateExpression = {"[3]+[11]", "[4]+[12]", "[5]+[13]", "[6]+[14]", "[7]+[15]", "[8]+[16]", "[9]+[17]",
				"[10]+[18]"};
		balanceTool.setBalanceIndex(balanceIndex);
		balanceTool.setRelateIndex(relateExpression);
		COutputTool outputTool = new COutputTool();
		String[][] strSummarys = getSummary(this.m_qryVO.getCurrTypeName(), this.m_qryVO.getFormatVO().getQryObjs());
		String[] strSummary = strSummarys[1];
		String[] strInitSummary = strSummarys[0];
		outputTool.setSimpleSummary(true);
		outputTool.setInitSummary(strInitSummary);
		outputTool.setSummary(strSummary);
		outputTool.setSummaryCol(90);
		outputTool.setRequireOutputDetail(true);
		outputTool.setGenTool((IGenTool) genTool);
		CDataSource datasource = new CDataSource();
		datasource.setSumVector(CDataSource.sortVector(vecVO, (ISortTool) genTool, false));
		CIntelVO tt = new CIntelVO();
		tt.setSumTool((ISumTool) sumTool);
		try {
			tt.setGenTool((IGenTool) genTool);
			tt.setBalanceTool((IBalanceTool) balanceTool);
			tt.setDatasource((IDataSource) datasource);
			tt.setOutputTool((IOutputTool) outputTool);
			tt.setTotalSumTool((ISumTool) sumTool);
			Vector recVector = tt.getResultVector();
			vos = new BalanceSubjAssBSVO[recVector.size()];
			recVector.copyInto((Object[]) vos);
			return addSumAllMark(vos);
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
			throw new Exception(e.getMessage());
		}
	}

	private BalanceSubjAssBSVO[] computeBalance(BalanceSubjAssBSVO[] vos) throws Exception {
		int[] intSortIndex;
		Vector<BalanceSubjAssBSVO> vecVO = new Vector();
		if (vos == null || vos.length == 0)
			return null;
		for (int i = 0; i < vos.length; i++)
			vecVO.addElement(vos[i]);
		CGenTool genTool = new CGenTool();
		int intSumLimit = 0;
		if (this.m_qryVO.getCurrTypeName().equals(CurrTypeConst.ALL_CURRTYPE())) {
			if (this.m_qryVO.isMultiCorpCombine() || (this.m_qryVO.getpk_accountingbook()).length == 1) {
				intSortIndex = new int[]{43, 45, 49, 0};
			} else {
				intSortIndex = new int[]{43, 45, 102, 49, 0};
			}
		} else if (this.m_qryVO.isMultiCorpCombine() || (this.m_qryVO.getpk_accountingbook()).length == 1) {
			intSortIndex = new int[]{43, 45, 0};
		} else {
			intSortIndex = new int[]{43, 45, 102, 0};
		}
		genTool.setSortIndex(intSortIndex);
		genTool.setLimitSumGen(intSumLimit);
		genTool.setUpSumGen(0);
		UFDCBalanceTool balanceTool = new UFDCBalanceTool();
		int[] balanceIndex = {27, 28, 29, 30, 31, 32, 33, 34, 123, 124, 125, 126};
		String[] relateExpression = {"[3]+[11]", "[4]+[12]", "[5]+[13]", "[6]+[14]", "[7]+[15]", "[8]+[16]", "[9]+[17]",
				"[10]+[18]", "[111]+[115]", "[112]+[116]", "[113]+[117]", "[114]+[118]"};
		balanceTool.setBalanceIndex(balanceIndex);
		balanceTool.setRelateIndex(relateExpression);
		COutputTool outputTool = new COutputTool();
		CDataSource datasource = new CDataSource();
		datasource.setSumVector(CDataSource.sortVector(vecVO, (ISortTool) genTool, false));
		CIntelVO tt = new CIntelVO();
		try {
			if (intSortIndex != null)
				tt.setGenTool((IGenTool) genTool);
			tt.setBalanceTool((IBalanceTool) balanceTool);
			tt.setDatasource((IDataSource) datasource);
			tt.setOutputTool((IOutputTool) outputTool);
			Vector recVector = tt.getResultVector();
			vos = new BalanceSubjAssBSVO[recVector.size()];
			recVector.copyInto((Object[]) vos);
			return vos;
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
			throw new Exception(e.getMessage());
		}
	}

	public BalanceSubjAssBSVO[] dealQuery(GlQueryVO p_qryVO) throws BusinessException {
		query(p_qryVO);
		BalanceSubjAssBSVO[] allAssBalanceVO = this.m_dataVOs;
		return allAssBalanceVO;
	}

	private BalanceSubjAssBSVO[] filterByBalanceOrientAndAmount(BalanceSubjAssBSVO[] vos, GlQueryVO p_qryVO) {
		try {
			int orient = p_qryVO.getFormatVO().getBalanceOrient();
			double dblRangeFrom = p_qryVO.getFormatVO().getBalanceRangeFrom().doubleValue();
			double dblRangeTo = p_qryVO.getFormatVO().getBalanceRangeTo().doubleValue();
			if (vos == null || vos.length == 0 || (orient == -1 && dblRangeFrom == 0.0D && dblRangeTo == 0.0D))
				return vos;
			Vector<BalanceSubjAssBSVO> result = new Vector();
			for (int i = 0; i < vos.length; i++) {
				double locValue = (vos[i].getEndLocAmount() == null) ? 0.0D : vos[i].getEndLocAmount().doubleValue();
				int endOri = vos[i].getEndOrient().intValue();
				if (orient == endOri)
					if (dblRangeFrom == 0.0D && dblRangeTo == 0.0D) {
						result.addElement(vos[i]);
					} else if (locValue >= dblRangeFrom && locValue <= dblRangeTo) {
						result.addElement(vos[i]);
					}
				if (orient == -1)
					if (dblRangeFrom == 0.0D && dblRangeTo == 0.0D) {
						result.addElement(vos[i]);
					} else if (locValue >= dblRangeFrom && locValue <= dblRangeTo) {
						result.addElement(vos[i]);
					}
			}
			vos = new BalanceSubjAssBSVO[result.size()];
			result.copyInto((Object[]) vos);
		} catch (Exception exception) {
		}
		return vos;
	}

	public BalanceSubjAssBSVO[] getData() {
		return this.m_dataVOs;
	}

	public IGenToolElement getGenToolElement(Object objKey) {
		if (objKey.equals(Integer.valueOf(45))) {
			if (this.m == null) {
				try {
					this.m = new CAccountGenToolElement(this.m_qryVO.getBaseAccountingbook());
				} catch (Exception e) {
					Logger.error(e.getMessage(), e);
				}
			} else {
				String pk_toolorgbook = ((CAccountGenToolElement) this.m).getpk_accountingbook();
				String pk_thisorgbook = this.m_qryVO.getBaseAccountingbook();
				if (!pk_thisorgbook.equals(pk_toolorgbook))
					try {
						this.m = new CAccountGenToolElement(this.m_qryVO.getBaseAccountingbook());
					} catch (Exception e) {
						Logger.error(e.getMessage(), e);
					}
			}
			return this.m;
		}
		if (objKey.equals(Integer.valueOf(80))) {
			if (this.assGenElement == null) {
				this.assGenElement = (IGenToolElement) new CAssGenToolElement();
				((CAssGenToolElement) this.assGenElement).setAssCodeLevel(new int[]{4, 3, 3, 3});
			}
			return this.assGenElement;
		}
		return null;
	}

	private int getLimitSumGen(String strCurrTypeName, GLQueryObj[] glQryObjs) {
		int intSumgenLimit = 0;
		for (int i = 0; i < glQryObjs.length; i++) {
			if (!glQryObjs[i].getType()
					.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000031")))
				if (glQryObjs[i].getType().endsWith(AssAttributesConst.getAttrTirmStr())) {
					for (int j = 0; j < (glQryObjs[i].getAttrsValues()).length; j++)
						intSumgenLimit++;
				} else {
					intSumgenLimit++;
				}
		}
		return intSumgenLimit;
	}

	private int[] getSortIndex(int iType) {
		int[] intSortIndex = null;
		String strCurrTypeName = this.m_qryVO.getCurrTypeName();
		GLQueryObj[] glQryObjs = this.m_qryVO.getFormatVO().getQryObjs();
		Vector<Integer> vTemp = new Vector();
		if (strCurrTypeName.equals(CurrTypeConst.ALL_CURRTYPE()))
			vTemp.add(Integer.valueOf(49));
		int n = -1;
		int flag = 0;
		int adjustValue = 0;
		for (int i = 0; i < glQryObjs.length; i++) {
			if (glQryObjs[i].getType()
					.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000031"))) {
				n++;
				adjustValue--;
				if (iType == 0) {
					vTemp.add(Integer.valueOf(45));
				} else if (iType == 1) {
					vTemp.add(Integer.valueOf(46));
				}
			} else if (glQryObjs[i].getType().endsWith(AssAttributesConst.getAttrTirmStr())) {
				for (int k = 0; k < (glQryObjs[i].getAttrsValues()).length; k++) {
					n++;
					addSortIndexByPos(vTemp, n + adjustValue, flag);
					flag++;
				}
			} else {
				n++;
				addSortIndexByPos(vTemp, n + adjustValue, flag);
				flag++;
			}
		}
		String tempyear = this.m_qryVO.getYear();
		String tempendyear = this.m_qryVO.getEndYear();
		if (!tempyear.equals(tempendyear))
			vTemp.add(Integer.valueOf(43));
		intSortIndex = new int[vTemp.size()];
		for (int j = 0; j < vTemp.size(); j++)
			intSortIndex[j] = ((Integer) vTemp.elementAt(j)).intValue();
		return intSortIndex;
	}

	private void addSortIndexByPos(Vector<Integer> vTemp, int pos, int flag) {
		if (pos == 0) {
			vTemp.insertElementAt(Integer.valueOf(85), flag);
			vTemp.add(Integer.valueOf(80));
		} else if (pos == 1) {
			vTemp.insertElementAt(Integer.valueOf(86), flag);
			vTemp.add(Integer.valueOf(81));
		} else if (pos == 2) {
			vTemp.insertElementAt(Integer.valueOf(82), flag);
			vTemp.add(Integer.valueOf(87));
		} else if (pos == 3) {
			vTemp.insertElementAt(Integer.valueOf(78), flag);
			vTemp.add(Integer.valueOf(83));
		} else if (pos == 4) {
			vTemp.insertElementAt(Integer.valueOf(79), flag);
			vTemp.add(Integer.valueOf(93));
		} else if (pos == 5) {
			vTemp.insertElementAt(Integer.valueOf(88), flag);
			vTemp.add(Integer.valueOf(94));
		} else if (pos == 6) {
			vTemp.insertElementAt(Integer.valueOf(89), flag);
			vTemp.add(Integer.valueOf(95));
		} else if (pos == 7) {
			vTemp.insertElementAt(Integer.valueOf(91), flag);
			vTemp.add(Integer.valueOf(96));
		} else if (pos == 8) {
			vTemp.insertElementAt(Integer.valueOf(97), flag);
			vTemp.add(Integer.valueOf(92));
		}
	}

	public ISortTool getSortTool(Object objCompared) {
		try {
			if (objCompared != null) {
				Object[] temps = (Object[]) objCompared;
				if (temps.length > 0 && temps[0] instanceof String)
					return (ISortTool) new CStringArraySortTool();
			}
			return (ISortTool) new CAssSortTool();
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
			return null;
		}
	}

	private Vector getSumEle() {
		String strCurrTypeName = this.m_qryVO.getCurrTypeName();
		GLQueryObj[] glQryObjs = this.m_qryVO.getFormatVO().getQryObjs();
		int iCorpDispPos = this.m_qryVO.getFormatVO().getCorpDispLocation();
		Vector<String> vTemp = new Vector();
		if (strCurrTypeName.equals(CurrTypeConst.ALL_CURRTYPE()))
			vTemp.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000119"));
		if (iCorpDispPos == 1 && !this.m_qryVO.isMultiCorpCombine() && (this.m_qryVO.getpk_accountingbook()).length > 1)
			vTemp.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000471"));
		for (int i = 0; i < glQryObjs.length; i++) {
			if (glQryObjs[i].getAccEle())
				if (glQryObjs[i].getType()
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000031"))) {
					vTemp.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000121"));
				} else if (!glQryObjs[i].getType().endsWith(AssAttributesConst.getAttrTirmStr())) {
					vTemp.add(glQryObjs[i].getType()
							+ NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000122"));
				} else {
					for (int j = 0; j < (glQryObjs[i].getAttrsValues()).length; j++)
						vTemp.add(glQryObjs[i].getAttrsValues()[j].getName() + "(" + glQryObjs[i].getType() + ")"
								+ NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000122"));
				}
		}
		if (iCorpDispPos == 0 && !this.m_qryVO.isMultiCorpCombine() && (this.m_qryVO.getpk_accountingbook()).length > 1)
			vTemp.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000120"));
		String tempyear = this.m_qryVO.getYear();
		String tempendyear = this.m_qryVO.getEndYear();
		if (!tempyear.equals(tempendyear))
			vTemp.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000117"));
		if (vTemp.size() != 0
				&& !vTemp.lastElement()
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000119"))
				&& !vTemp.lastElement()
						.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000471")))
			vTemp.removeElementAt(vTemp.size() - 1);
		return vTemp;
	}

	private String[][] getSummary(String strCurrTypeName, GLQueryObj[] glQryObjs) {
		Vector<String> vInitSummary = new Vector();
		Vector<String> vSummary = new Vector();
		int flag = 0;
		if (strCurrTypeName.equals(CurrTypeConst.ALL_CURRTYPE())) {
			vInitSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000459"));
			vSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000119"));
		}
		for (int i = 0; i < glQryObjs.length; i++) {
			if (glQryObjs[i].getType()
					.equals(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000031"))) {
				vInitSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000540"));
				vSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000121"));
			} else if (!glQryObjs[i].getType().endsWith(AssAttributesConst.getAttrTirmStr())) {
				vInitSummary.insertElementAt(null, flag);
				vSummary.insertElementAt(null, flag);
				flag++;
				vInitSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000540"));
				vSummary.add(glQryObjs[i].getType()
						+ NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000122"));
			} else {
				for (int k = 0; k < (glQryObjs[i].getAttrsValues()).length; k++) {
					vInitSummary.insertElementAt(null, flag);
					vSummary.insertElementAt(null, flag);
					flag++;
					vInitSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000540"));
					vSummary.add(glQryObjs[i].getAttrsValues()[k].getName() + "(" + glQryObjs[i].getType() + ")"
							+ NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000122"));
				}
			}
		}
		if (!GlQueryVOBookTool.isSameYear(this.m_qryVO)) {
			vInitSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000459"));
			vSummary.add(NCLangRes4VoTransl.getNCLangRes().getStrByID("20023030", "UPP20023030-000117"));
		}
		String[][] strSummarys = new String[2][vInitSummary.size()];
		for (int j = 0; j < vInitSummary.size(); j++) {
			strSummarys[0][j] = (vInitSummary.elementAt(j) == null) ? null : vInitSummary.elementAt(j).toString();
			strSummarys[1][j] = (vSummary.elementAt(j) == null) ? null : vSummary.elementAt(j).toString();
		}
		return strSummarys;
	}

	private GlBalanceVO[][] getVO(GlQueryVO[] param) throws Exception {
		Vector<GlBalanceVO> vRet0 = new Vector();
		Vector<GlBalanceVO> vRet1 = new Vector();
		Vector<GlBalanceVO> vRet2 = new Vector();
		GlBalanceVO[][] voTemp = new GlBalanceVO[3][];
		GlBalanceVO[][] voRet = new GlBalanceVO[3][];
		this.accPkMap.clear();
		this.qryAccCodeMap.clear();
		IRemoteBillModel billModel = (IRemoteBillModel) NCLocator.getInstance().lookup(IRemoteBillModel.class);
		Map<String, BalanceResultVO> rstMap = billModel.queryAssPropBalance(param);
		for (int i = 0; i < param.length; i++) {
			try {
				BalanceResultVO balanceVo = rstMap.get(param[i].getpk_accountingbook()[0]);
				voTemp = balanceVo.bsVo;
				for (AccountVO accvo : balanceVo.asv) {
					this.accPkMap.put(accvo.getPk_accasoa(), accvo);
					for (String code : this.m_qryVO.getAccountCode()) {
						if (accvo.getCode().equals(code))
							this.qryAccCodeMap.put(accvo.getCode(), accvo);
					}
				}
				if (voTemp[0] != null && (voTemp[0]).length > 0)
					for (int j = 0; j < (voTemp[0]).length; j++)
						vRet0.addElement(voTemp[0][j]);
				if (voTemp[1] != null && (voTemp[1]).length > 0)
					for (int j = 0; j < (voTemp[1]).length; j++)
						vRet1.addElement(voTemp[1][j]);
				if (voTemp[2] != null && (voTemp[2]).length > 0)
					for (int j = 0; j < (voTemp[2]).length; j++)
						vRet2.addElement(voTemp[2][j]);
			} catch (Exception e) {
				Logger.error(e.getMessage(), e);
			}
		}
		if (vRet0.size() > 0) {
			voRet[0] = new GlBalanceVO[vRet0.size()];
			vRet0.copyInto((Object[]) voRet[0]);
		}
		if (vRet1.size() > 0) {
			voRet[1] = new GlBalanceVO[vRet1.size()];
			vRet1.copyInto((Object[]) voRet[1]);
		}
		if (vRet2.size() > 0) {
			voRet[2] = new GlBalanceVO[vRet2.size()];
			vRet2.copyInto((Object[]) voRet[2]);
		}
		return voRet;
	}

	private boolean includeInAssvos(AssVO vo, AssVO[] vos) throws Exception {
		for (int i = 0; i < vos.length; i++) {
			if (vo.getPk_Checktype().equals(vos[i].getPk_Checktype())
					&& vo.getCheckvaluecode().equals(vos[i].getCheckvaluecode()))
				return true;
		}
		return false;
	}

	private void initQueryVO(GlQueryVO param) throws Exception {
		this.m_qryVO = (GlQueryVO) param.clone();
		AssVO[] assInfo = this.m_qryVO.getAssVos();
		String pk_corp = getPk_corp(this.m_qryVO.getBaseAccountingbook());
		for (int i = 0; i < assInfo.length; i++) {
			if (((Boolean) assInfo[i].getUserData()).booleanValue())
				assInfo[i] = CAssTool.containSubDocsTackle(assInfo[i], pk_corp);
		}
		this.m_qryVO.setAssVos(assInfo);
		AssAttriVODealTool.addSubAttrDocs(this.m_qryVO.getFormatVO().getQryObjs(), pk_corp);
		GlQueryVOTool tool = new GlQueryVOTool();
		this.queryVOs = tool.classifyQueryVO(this.m_qryVO, true);
		if (this.m_qryVO.getCurrTypeName().equals(CurrTypeConst.AUX_CURRTYPE())
				|| this.m_qryVO.getCurrTypeName().equals(CurrTypeConst.QUERY_LOC_CURRTYPE())) {
			if (this.m_qryVO.getFormatVO().isMultiCorpCombine()) {
				this.m_qryVO.setGroupFields(new int[]{4, 2, 19});
			} else {
				this.m_qryVO.setGroupFields(new int[]{4, 31, 2, 19});
			}
		} else if (this.m_qryVO.getFormatVO().isMultiCorpCombine()) {
			this.m_qryVO.setGroupFields(new int[]{4, 2, 7, 19});
		} else {
			this.m_qryVO.setGroupFields(new int[]{4, 31, 2, 7, 19});
		}
		for (int j = 0; j < this.queryVOs.length; j++) {
			this.queryVOs[j].setGroupFields(this.m_qryVO.getGroupFields());
			if (this.m_qryVO.getFormatVO().isIsQryByCorpAss())
				this.queryVOs[j] = tool.tackleDoc(this.queryVOs[j])[0];
		}
	}

	private void query(GlQueryVO p_qryVO) throws BusinessException {
		GlBalanceVO[] initVOs = null;
		GlBalanceVO[] occurVOs = null;
		GlBalanceVO[] accumVOs = null;
		saveAssInfo(p_qryVO);
		try {
			initQueryVO((GlQueryVO) p_qryVO.clone());
			String baseorgbook = p_qryVO.getBaseAccountingbook();
			for (int i = 0; i < this.queryVOs.length; i++)
				this.queryVOs[i].setBaseAccountingbook(null);
			GlBalanceVO[][] vos = getVO(this.queryVOs);
			for (int j = 0; j < this.queryVOs.length; j++)
				this.queryVOs[j].setBaseAccountingbook(baseorgbook);
			initVOs = vos[0];
			occurVOs = vos[1];
			accumVOs = vos[2];
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
		}
		BalanceSubjAssBSVO[] bsvos = null;
		try {
			bsvos = appendInitVOs(bsvos, initVOs, p_qryVO.getM_Return_CurrType());
			bsvos = appendOccurVOs(bsvos, occurVOs, p_qryVO.getM_Return_CurrType());
			bsvos = appendAccumVOs(bsvos, accumVOs, p_qryVO.getM_Return_CurrType());
			bsvos = appendAccInfo(bsvos, p_qryVO);
			bsvos = appendAssInfo(bsvos, p_qryVO);
		} catch (Exception err) {
			Logger.error(err.getMessage(), err);
		}
		try {
			boolean blnHasFatherAndSon = this.m_qryVO.getFormatVO().isIsSubjAccIncldFatherSon();
			boolean blnAssHasFatherAndSon = this.m_qryVO.getFormatVO().isIsAssIncldFatherSon();
			if (!blnHasFatherAndSon) {
				bsvos = changeAccInfo(bsvos);
				bsvos = combineAss(bsvos);
			}
			bsvos = computeBalance(bsvos);
			bsvos = filterOfHasBalanceButNoOccur(bsvos, p_qryVO);
			bsvos = filterByBalanceOrientAndAmount(bsvos, p_qryVO);
			bsvos = compute(bsvos);
			bsvos = adjustOrgBookInfo(bsvos);
			bsvos = adjustCurrType(bsvos);
			bsvos = adjustContent(bsvos);
			if (blnHasFatherAndSon)
				bsvos = changeAccInfoFaS(bsvos);
			if (blnAssHasFatherAndSon)
				bsvos = changeAssInfoFaS(bsvos, p_qryVO);
			if ((p_qryVO.getpk_accountingbook()).length > 1 && !p_qryVO.getFormatVO().isMultiCorpCombine()
					&& !p_qryVO.getFormatVO().isIsCorpSubjDspBase())
				bsvos = adjustAccInfo(bsvos);
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
		}
		if (bsvos == null || bsvos.length == 0) {
			this.m_dataVOs = null;
		} else {
			this.m_dataVOs = bsvos;
		}
	}

	public BalanceSubjAssBSVO[] getSettleedDatas(BalanceSubjAssBSVO[] bsvos, GlQueryVO p_qryVO) throws Exception {
		try {
			boolean blnHasFatherAndSon = this.m_qryVO.getFormatVO().isIsSubjAccIncldFatherSon();
			boolean blnAssHasFatherAndSon = this.m_qryVO.getFormatVO().isIsAssIncldFatherSon();
			if (!blnHasFatherAndSon) {
				bsvos = changeAccInfo(bsvos);
				bsvos = combineAss(bsvos);
			}
			bsvos = computeBalance(bsvos);
			bsvos = filterOfHasBalanceButNoOccur(bsvos, p_qryVO);
			bsvos = filterByBalanceOrientAndAmount(bsvos, p_qryVO);
			bsvos = compute(bsvos);
			bsvos = adjustOrgBookInfo(bsvos);
			bsvos = adjustCurrType(bsvos);
			bsvos = adjustContent(bsvos);
			if (blnHasFatherAndSon)
				bsvos = changeAccInfoFaS(bsvos);
			if (blnAssHasFatherAndSon)
				bsvos = changeAssInfoFaS(bsvos, p_qryVO);
			if ((p_qryVO.getpk_accountingbook()).length > 1 && !p_qryVO.getFormatVO().isMultiCorpCombine()
					&& !p_qryVO.getFormatVO().isIsCorpSubjDspBase())
				bsvos = adjustAccInfo(bsvos);
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
		}
		return bsvos;
	}

	public BalanceSubjAssBSVO[] queryOnly(GlQueryVO p_qryVO) throws Exception {
		GlBalanceVO[] initVOs = null;
		GlBalanceVO[] occurVOs = null;
		GlBalanceVO[] accumVOs = null;
		saveAssInfo(p_qryVO);
		try {
			initQueryVO((GlQueryVO) p_qryVO.clone());
			String baseorgbook = p_qryVO.getBaseAccountingbook();
			for (int i = 0; i < this.queryVOs.length; i++)
				this.queryVOs[i].setBaseAccountingbook(null);
			GlBalanceVO[][] vos = getVO(this.queryVOs);
			for (int j = 0; j < this.queryVOs.length; j++)
				this.queryVOs[j].setBaseAccountingbook(baseorgbook);
			initVOs = vos[0];
			occurVOs = vos[1];
			accumVOs = vos[2];
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
		}
		BalanceSubjAssBSVO[] bsvos = null;
		try {
			bsvos = appendInitVOs(bsvos, initVOs, p_qryVO.getM_Return_CurrType());
			bsvos = appendOccurVOs(bsvos, occurVOs, p_qryVO.getM_Return_CurrType());
			bsvos = appendAccumVOs(bsvos, accumVOs, p_qryVO.getM_Return_CurrType());
			bsvos = appendAccInfo(bsvos, p_qryVO);
			bsvos = appendAssInfo(bsvos, p_qryVO);
		} catch (Exception ex) {
			Logger.error(ex.getMessage(), ex);
		}
		return bsvos;
	}

	private void saveAssInfo(GlQueryVO p_qryVO) throws BusinessException {
		GLQueryObj[] qryObjs = p_qryVO.getFormatVO().getQryObjs();
		this.topLevelAssInfo.clear();
		for (int i = 0; i < qryObjs.length; i++) {
			if (qryObjs[i].getLinkObj() != null) {
				AssVO[] ass = (AssVO[]) qryObjs[i].getLinkObj();
				for (int k = 0; k < ass.length; k++) {
					if (qryObjs[i].getValueRange() != null) {
						ass[k].setChecktypecode(qryObjs[i].getValueRange()[0].getChecktypecode());
						ass[k].setChecktypename(qryObjs[i].getValueRange()[0].getChecktypename());
					}
				}
				BalanceSubjAssBSVO[] vo = new BalanceSubjAssBSVO[1];
				vo[0] = new BalanceSubjAssBSVO();
				vo[0].setValue(0, ass);
				AssCodeConstructor constructor = new AssCodeConstructor();
				try {
					constructor.constructAssCode(getPk_corp(p_qryVO.getBaseAccountingbook()), (IVoAccess[]) vo, 0);
					ass = (AssVO[]) vo[0].getValue(0);
				} catch (Exception e) {
					throw new BusinessException(e.getMessage(), e);
				}
				for (int j = 0; j < ass.length; j++)
					this.topLevelAssInfo.put(ass[j].getPk_Checktype() + ass[j].getInnerCode(), ass[j]);
			}
		}
	}

	public String getPk_corp(String Pk_orgbook) {
		String corp = null;
		try {
			corp = AccountBookUtil.getPk_org(Pk_orgbook);
		} catch (Exception ex) {
			Logger.error(ex.getMessage(), ex);
		}
		return corp;
	}
}